/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author VANDH
 */
package demo.substring;

public class SubString {

    public static void main(String[] args) {
        // Cách 1
        String s = "012345678912";
        for (int i = 0; i < s.length(); i++) {
            System.out.print(s.charAt(i));
            if ((i + 1) % 3 == 0) {
                System.out.println();
            }
        }

        // Cách 2
        System.out.println(s.substring(0, 3));
        System.out.println(s.substring(3, 6));
        System.out.println(s.substring(6, 9));
        System.out.println(s.substring(9, 12));

        // Cách 3
        for (int i = 0; i < 12; i += 3) {
            System.out.println(s.substring(i, i + 3));
        }
    }
}
